/*
 * @Author: lixiangqun
 * @Date: 2025-11-16 17:25:12
 * @LastEditors: lixiangqun
 * @LastEditTime: 2025-11-16 18:14:36
 * @Description:
 * @FilePath: \electrconVue\src\provider\createProvider.ts
 */
import { BaseProvider } from "./BaseProvider";
import { OpenAIProvider } from "./OpenAIProvider";
import { QianfanProvider } from "./QianfanProvider";

export function createProvider(providerName: string): BaseProvider {
  switch (providerName) {
    case "qianfan":
      return new QianfanProvider(
        process.env.OPENAI_API_KEY as string,
        "https://qianfan.baidubce.com/v2/"
      );
    case "dashscope":
      return new OpenAIProvider(
        process.env.ALI_API_KEY as string,
        "https://dashscope.aliyuncs.com/compatible-mode/v1"
      );
    default:
      throw new Error(`Unsupported provider: ${providerName}`);
  }
}
